package com.xatz.scanner

import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.xatz.scanner.databinding.ActivityBarCodeBinding

/**
 * author: tdq
 * date: 2021/7/20
 * description: 条码录入
 */
class BarCodeActivity : AppCompatActivity() {

    private lateinit var mBinding: ActivityBarCodeBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mBinding = ActivityBarCodeBinding.inflate(layoutInflater)
        setContentView(mBinding.root)

        mBinding.tlLayout.setRightViewOnClick {
            val num = mBinding.etNum.text?.trim().toString()
            if (num.isEmpty()) {
                Toast.makeText(this, "请输入条形码号", Toast.LENGTH_SHORT).show()
                return@setRightViewOnClick
            }
            intent.putExtra("numText", num)
            setResult(RESULT_OK, intent)
            finish()
        }
    }
}